//
// Created by Administrator on 2023/7/30.
//
#include <string>
#include <iostream>

using namespace std;

class Solution {
public:
    string makeSmallestPalindrome(string s) {
        // 贪心就可以
        int i = 0, j = s.size() - 1;
        while (i < j) {
            if (s[i] < s[j])
                s[j] = s[i];
            else
                s[i] = s[j];
            i++;
            j--;
        }
        return s;
    }
};

class Solution2 {
public:
    string makeSmallestPalindrome(string s) {
        for (int i = 0, j = s.size() - 1; i < j; i++, j--) {
            if (s[i] != s[j]) {
                if (s[i] < s[j])
                    s[j] = s[i];
                else
                    s[i] = s[j];
            }
        }
        return s;
    }
};

int main() {
    Solution s;
    cout << s.makeSmallestPalindrome("egcfe") << endl;
    cout << s.makeSmallestPalindrome("abcd") << endl;
    cout << s.makeSmallestPalindrome("seven") << endl;
}